<template>
	<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
			
		 
		  <el-form-item label="供应商名称" prop="sname">
			<el-input v-model="ruleForm.sname"></el-input>
		  </el-form-item>
		  <el-form-item label="供应商简称" prop="sshort">
			<el-input v-model="ruleForm.sshort"></el-input>
		  </el-form-item>
		  <el-form-item label="地址" prop="saddress">
			<el-input v-model="ruleForm.saddress"></el-input>
		  </el-form-item>
		  <el-form-item label="公司电话" prop="sphone">
			<el-input v-model="ruleForm.sphone"></el-input>
		  </el-form-item>
		  <el-form-item label="邮件" prop="semile">
			<el-input v-model="ruleForm.semile"></el-input>
		  </el-form-item>
		  <el-form-item label="联系人" prop="slinkman">
		  			<el-input v-model="ruleForm.slinkman"></el-input>
		  </el-form-item>
		  <el-form-item label="联系人电话" prop="slinkmanphone">
		  			<el-input v-model="ruleForm.slinkmanphone"></el-input>
		  </el-form-item>
		  <el-form-item label="备注" prop="sremark">
		  			<el-input v-model="ruleForm.sremark"></el-input>
		  </el-form-item>
		  

		  <el-form-item>
			<el-button type="primary" @click="submitForm('ruleForm')">新建信息</el-button>
			 <el-button @click="resetForm('ruleForm')">重置</el-button>
		  </el-form-item>
	</el-form>
</template>
<script>
  export default {
	  name: "SupplierAdd",
			data() {
			  return {
				ruleForm: {
				  
				  sname:'',
				  sshort:'',
				  saddress:'',
				  sphone:'',
				  semile:'' ,
				  slinkman:'',
				  slinkmanphone:'',
				  sremark:''			  
				},
				rules: {
						
				}
			  };
			},
			methods: {
			 submitForm(formName) {
				 const _this = this;
			         this.$refs[formName].validate((valid) => {
			           if (valid) {
							axios.post('http://localhost:8181/supplier/save',this.ruleForm).then(function(resp){
								console.log("resp");
								if(resp.data == 'success'){
									_this.$message('添加成功！');
									_this.$router.push('/SupplierSearch')
								}
							})
			           } else {
			             console.log('error submit!!');
			             return false;
			           }
			         });
			       },
			       resetForm(formName) {
			         this.$refs[formName].resetFields();
			       }
			     }
		  }
</script>